home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / cbm / 4911 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.9 KB

  1. Path: flash.LakeheadU.Ca!jgvotour
  2. From: jgvotour@flash.LakeheadU.Ca (Bonestripper/Omni)
  3. Newsgroups: comp.sys.cbm
  4. Subject: Re: Scanning strings under BASIC, avoiding INPUT "?"
  5. Message-ID: <23371@storm.LakeheadU.Ca>
  6. Date: 1 Apr 1996 15:50:51 GMT
  7. References: <4jc9kt$h3p@news.rrz.uni-koeln.de>
  8. Sender: news@storm.LakeheadU.Ca
  9. Organization: Lakehead University
  10. X-Newsreader: TIN [version 1.2 PL1]
  11.  
  12. Joerg Bleimann (a2233495@rrz.Uni-Koeln.DE) wrote:
  13. : Hi Freaks!
  14.  
  15. : I have got a problem with COMMODORE BASIC 2.0: I started programming a text
  16. : adventure on the C 64 and do not know how to make the computer recognize the
  17. : latter part of a bipartite command string (for example "TAKE BOTTLE"). How
  18. : can I search the whole string for empties (" ") to redefine the part right
  19. : from the empty as a new string? ASC only recognizes the first character of a
  20. : string, VAL takes only number characters into account... and machine language
  21. : is all Greek to me!
  22. : Yet another question: in more modern BASIC dialects, one can avoid the ? after
  23. : INPUT by typing a comma before the variable; in CBM BASIC 2.0 this would pro-
  24. : duce a SYNTAX ERROR. Are there any ways to get rid of the question mark using
  25. : BASIC on the C 64?
  26.  
  27. :                           See you in Khyberspace!
  28.  
  29. :                           Joerg "Yadgar Achakzai" Bleimann
  30.  
  31. :                           The Virtual Afghan
  32.  
  33. To avoid the question mark, you can put a POKE 19,0 before the INPUT command
  34. and then put a POKE 19,65 afterwards (I think that's the order, if not
  35. reverse the POKE commands, ie. POKE 19,65:INPUT...:POKE19,0).  Unfortunately,
  36. this plays with the computer a little bit....
  37. For the ohter thing, you will have to either make your own loop using GET (to
  38. get a character at a time and parse it as you go), or you can use the MID$
  39. or RIGHT$ functions to extract pieces of text.
  40. For example, I enter the command GET KEY (a common text adventure command)
  41. so, say A$ now contains "GET KEY".  To play with that I can :
  42. B$ = RIGHT$(A$,3) --> B$ now contains "KEY"
  43. Basically, I believe that you want to determine where a command ends and
  44. where the parameters kick in (GET being the command and KEY being the
  45. parameter).  So,
  46.  
  47. 10 X=0:REM INDEX INTO STRING (A$)
  48. 20 IF MID$(A$,X,1)=" "THEN50
  49. 30 C$=C$+MID$(A$,X,1):REM ASSEMBLE THE COMMAND
  50. 40 X=X+1:GOTO20:REM INCREMENT INDEX AND GET NEXT LETTER OF COMMAND
  51. 50 B$=RIGHT$(A$,LEN(A$)-X):REM PUT THE OBJECT/WHATEVER INTO B$
  52.  
  53. That should do it (it has been a while since I have done BASIC - I usually
  54. work in Assembly Language on most of my tasks, since BASIC is a little slow
  55. for the stuff that I do...  By the way, the program assumes that A$ contains
  56. the complete command (ie. GET KEY) and then it makes C$ the command that
  57. was typed (GET) and B$ the object (KEY).  Note that if you were to enter a
  58. multi-part command that it would not split it all up - if you entered
  59. GET THE KEY, c$ would be GET and B$ would be THE KEY.
  60.  
  61. Whew! Hope that helps...
  62.  
  63.